﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Easy.Authorization.Models;
using Easy.Authorization.Repository;
using Easy.Authorization.Repository.Query;
using Easy.Common.RegisterType;


namespace Easy.Authorization.Business
{
    [RegisterType(typeof(Aut_NavigationsBusiness))]
    class Aut_NavigationsBusiness
    {
        IAut_NavigationsQueryRepository _Aut_NavigationsQueryRepository;
        IAut_NavigationsRepository _Aut_NavigationsRepository;

        public Aut_NavigationsBusiness(IAut_NavigationsQueryRepository Aut_NavigationsQueryRepository, IAut_NavigationsRepository Aut_NavigationsRepository)
        {
            _Aut_NavigationsQueryRepository = Aut_NavigationsQueryRepository;
            _Aut_NavigationsRepository = Aut_NavigationsRepository;
        }


        internal void CreateNew(Aut_Navigations aut_User)
        {
            _Aut_NavigationsRepository.Add(aut_User);

            _Aut_NavigationsRepository.UnitOfWork.Commit();
        }

        internal void Update(Aut_Navigations aut_User)
        {
            _Aut_NavigationsRepository.Update(aut_User);

            _Aut_NavigationsRepository.UnitOfWork.Commit();
        }

        internal void Delete(Guid aut_UserId)
        {
            _Aut_NavigationsRepository.Delete(aut_UserId);

            _Aut_NavigationsRepository.UnitOfWork.Commit();
        }

        internal IQueryable<VAut_Navigations> GetAll()
        {
            return _Aut_NavigationsQueryRepository.GetAll();
        }

        internal IQueryable<VAut_Navigations> GetRootNavigation()
        {
            return _Aut_NavigationsQueryRepository.GetRootNavigation();
        }

        internal IQueryable<VAut_Navigations> GetChildrenNavigations(string navigationDispaly)
        {
            return _Aut_NavigationsQueryRepository.GetChildrenNavigations(navigationDispaly);
        }
    }
}
